home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
vol_200
/
281_01
/
window.c
< prev
next >
Wrap
C/C++ Source or Header
|
1988-10-05
|
24KB
|
839 lines
/* window.c
*
* Demo program for uclib.lib Version 5.10
*
*/
/*--------------------------------------------------------------------*/
/* This program in no way illustrates each of the over 300 functions */
/* contained in uclib.lib version 5.10. It does however make an */
/* attempt to illustrate some of what can be done with the library. */
/*--------------------------------------------------------------------*/
#include <stdio.h> /* needed since NULL is used in uc_defs.h */
#ifdef MSC
#include <malloc.h>
#else
#include <alloc.h>
#endif
#include "uc_defs.h" /* Assume the headers are in the current */
#include "uc_glob.h" /* directory. */
#include "uc_proto.h"
#include "wn_defs.h"
#include "wn_glob.h"
#include "wn_proto.h"
extern WINDOWPTR err_wnd; /* Allow access to the system error window */
void main( void ) /* Unicorn Software programs are written */
{ /* using ANSI standard prototyping. */
WINDOWPTR wn_main;
WINDOWPTR wn_sub; /* sub window for the main screen window */
WINDOWPTR wn_1;
WINDOWPTR wn_2;
WINDOWPTR wn_3;
WINDOWPTR wn_4;
WINDOWPTR wn_5;
WINDOWPTR wn_6;
WINDOWPTR wn_7;
WINDOWPTR wn_8;
WINDOWPTR wn_9;
WINDOWPTR wn_10;
char *str_save();
char err_str[ 256 ]; /* error message string */
int i;
int count;
uc_init(); /* Inititalize various system values */
if ( mouse_exist )
m_flagdec();
cur_off(); /* Turn off the cursor to avoid clutter */
wn_main = wn_make( 0, 0, 25, 80 ); /* Define a window and size it */
/* Set the window normal attribute */
wn_wnclr( wn_main, mk_att( BLUE, BROWN + BRIGHT ) );
/* Set the window border attribute */
wn_bclr( wn_main, mk_att( BLUE, WHITE + BRIGHT ) );
wn_clear( wn_main ); /* Clear the window area */
/* Set up a window title - a future */
/* enhancement will allow more than one */
/* title to be placed in the window's */
/* border. Position parameters will */
/* also be allowed such as CENTER etc. */
/* Also functions will be added to set */
/* up the title directly without going */
/* through this indirect process. */
wn_main->title = ( TITLEPTR ) malloc( sizeof( TITLE ) );
wn_main->title->title = ( char * ) malloc( 100 );
strcpy( wn_main->title->title,
" Unicorn Software P.O. Box 3214 Kirkland, WA 98034-3214 (206) 823-4656" );
wn_main->title->position = 4;
/* Set the title color */
wn_main->clr->title = mk_att( WHITE, RED + BRIGHT );
/* Set the window's right & left margins*/
wn_margin( wn_main, 3 );
wn_mkbdr( wn_main, BDR_DLNP ); /* make a border for the window */
wn_sub = wn_make( 4, 5, 19, 72 ); /* Define a window and size it */
/* Set the window normal attribute */
wn_wnclr( wn_sub, mk_att( BLUE, BROWN + BRIGHT ) );
/* Set the window border attribute */
wn_bclr( wn_sub, mk_att( BLUE, WHITE + BRIGHT ) );
wn_clear( wn_sub ); /* Clear the window area */
wn_margin( wn_sub, 1 );
wn_mkbdr( wn_sub, BDR_SLNP ); /* make a border for the window */
/*--------------------------------------------------------------------*/
/* At this point the window has been defined and all parameters for */
/* the basic window, the title and border are contained in structures.*/
/* Next we will write some text to the window, even though it is not */
/* yet displayed on the screen, then the window will be displayed and */
/* finally further text will be written to the displayed window. */
/*--------------------------------------------------------------------*/
/* the following function writes a single*/
/* character to the window. */
wn_pchar( wn_main, '\n' );
for ( i = 0; i <= 25; i++ )
wn_pchar( wn_main, ' ' );
wn_pchar( wn_main, 'U' );
wn_pchar( wn_main, 'n' );
wn_pchar( wn_main, 'i' );
wn_pchar( wn_main, 'c' );
wn_pchar( wn_main, 'o' );
wn_pchar( wn_main, 'r' );
wn_pchar( wn_main, 'n' );
wn_pchar( wn_main, ' ' );
wn_pchar( wn_main, 'L' );
wn_pchar( wn_main, 'i' );
wn_pchar( wn_main, 'b' );
wn_pchar( wn_main, 'r' );
wn_pchar( wn_main, 'a' );
wn_pchar( wn_main, 'r' );
wn_pchar( wn_main, 'y' );
wn_pchar( wn_main, ' ' );
wn_pchar( wn_main, '5' );
wn_pchar( wn_main, '.' );
wn_pchar( wn_main, '0' );
wn_pchar( wn_main, '0' );
wn_pchar( wn_main, '\n' );
wn_pchar( wn_main, '\n' );
wn_wnclr( wn_sub, mk_att( BLUE, WHITE ) );
wn_printf( wn_sub,
"\nWelcome to version 5.10 of " );
wn_wnclr( wn_sub, mk_att( BLUE, CYAN + BRIGHT ) );
wn_printf( wn_sub,
"UCLIB.LIB" );
wn_wnclr( wn_sub, mk_att( BLUE, WHITE ) );
wn_printf( wn_sub,
". This all new version of\n" );
wn_printf( wn_sub,
"the library contains many differences from past releases. First\n" );
wn_printf( wn_sub,
"and foremost the library is now entirely in C, gone are the \n" );
wn_printf( wn_sub,
"assembler routines of past releases. This should make it much\n" );
wn_printf( wn_sub,
"easier for users to understand and work with the library source\n" );
wn_printf( wn_sub,
"code. An " );
wn_wnclr( wn_sub, mk_att( BLUE, WHITE + BRIGHT ) );
wn_printf( wn_sub,
"all new windowing package " );
wn_wnclr( wn_sub, mk_att( BLUE, WHITE ) );
wn_printf( wn_sub,
" is included as is the " );
wn_wnclr( wn_sub, mk_att( BLUE, WHITE + BRIGHT ) );
wn_printf( wn_sub,
"data\nentry system" );
wn_wnclr( wn_sub, mk_att( BLUE, WHITE ) );
wn_printf( wn_sub,
". The new windowing system allows you to write to\n" );
wn_printf( wn_sub,
"a window whether or not it is currently displayed on the screen.\n" );
wn_printf( wn_sub,
"The data entry system uses this windowing system for maximum user\n" );
wn_printf( wn_sub,
"flexibility. As this demo progresses it will stop at various points.\n" );
wn_printf( wn_sub,
"When this occurs simply press a key to continue. \n" );
wn_printf( wn_sub,
" \n" );
wn_dsply( wn_main );
wn_dsply( wn_sub ); /* display the window now!! */
gr_bckgnd( BLUE ); /* Set the border color */
uc_key(); /* get a user key stroke and ignore the key returned */
wn_printf( wn_sub,
"\nSee how simple that was! Now in this section please note\n" );
wn_printf( wn_sub,
"two important items, first the cursor has been turned off to\n" );
wn_printf( wn_sub,
"avoid unsightly screen clutter and secondly the main text of\n" );
wn_printf( wn_sub,
"this window will scroll as new lines are added. \n" );
uc_key();
wn_printf( wn_sub,
"\nIn this next section additional windows will be placed on the\n" );
wn_printf( wn_sub,
"screen. They will be moved in all three directions, text will\n" );
wn_printf( wn_sub,
"be written to them in addition to other suprises. \n" );
uc_key();
wn_1 = wn_make( 5, 5, 12, 40 );
wn_wnclr( wn_1, mk_att( RED, BROWN + BRIGHT ) );
wn_bclr( wn_1, mk_att( RED, WHITE + BRIGHT ) );
wn_clear( wn_1 );
wn_1->title = ( TITLEPTR ) malloc( sizeof( TITLE ) );
wn_1->title->title = ( char * ) malloc( 100 );
strcpy( wn_1->title->title, " Sub Window 1 " );
wn_1->title->position = 4;
wn_1->clr->title = mk_att( RED, WHITE + BRIGHT );
wn_margin( wn_1, 1 );
wn_mkbdr( wn_1, BDR_12LNP );
wn_dsply( wn_1 );
wn_printf( wn_1, "This window is currently in the\n" );
wn_printf( wn_1, "forefront and next another window\n" );
wn_printf( wn_1, "will be placed on the screen which\n" );
wn_printf( wn_1, "will partially obscure this one.\n" );
uc_key();
w